/*
 * Utiles.java
 *
 * Created on 28 de noviembre de 2003, 16:57
 */

package jmc.util.core;

import java.util.Random;

import com.sun.jmx.snmp.Timestamp;

/**
 *
 * @author  jmcarrascal
 */

public class Utiles {

	public static String getWebappsPath(){
        String sep = System.getProperty("file.separator");
        return System.getProperty("catalina.base") + sep + "webapps";
    }
    
	public static String llenoConZero(String valor){
		int tama = valor.length();
		while (tama < 3){
			valor = "0" + valor;
			tama = valor.length();
		}
		return valor;
	
	}

	public static boolean isUserAuthentication(int pass){
    	boolean valor = false;
    	
    	if (pass == getFormatedDate()){
    		valor = true;
    	}
    	return valor;
    }
    
    public static int getFormatedDate(){
    	Timestamp ts = new Timestamp(System.currentTimeMillis());
    	int fecha = ts.getDate().getMonth() + ts.getDate().getDate() + ts.getDate().getHours();
    	return fecha;
    }

    public static String getRandomNumber(){
		Random rand = new Random();
		int x = rand.nextInt(100000000);
		return String.valueOf(x).substring(0, 6);				
    }
    
    public static String getRandomNumberL5(){
		Random rand = new Random();
		int x = rand.nextInt(100000000);
		return String.valueOf(x).substring(0, 5);				
    }

}
